<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let fn1 = a => a + 1;
      console.log(fn1(1))  // 2
      
      var fn222 = function(a){
        return a + 1
      }

      const obj = {
        birth: 1988,
        getAge: function() {
          let b = this.birth; // 1988
          let fn = function() {
            return new Date().getFullYear() - this.birth; // this指向window或undefined
          };
          return fn();
        }
      };
      console.log(obj.getAge());

      const obj1 = {
        birth: 1988,
        getAge: function() {
          let b = this.birth; // 1988
          let fn = () => new Date().getFullYear() - this.birth; // this指向obj对象
          return fn();
        }
      };
      console.log(obj1.getAge()); // 31
    </script>
  </body>
</html>
